Class NewsRepositoryTest

java.lang.Object
com.fsf.news.repository.NewsRepositoryTest

@ExtendWith({GuiceExtension.class,org.mockito.junit.jupiter.MockitoExtension.class}) class NewsRepositoryTest extends Object
Unit tests for the NewsRepository class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) com.fasterxml.jackson.databind.ObjectMapper
     
    (package private) com.fsf.news.repository.NewsRepository
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Tests that the clearSession method removes all search results for a non-empty session.
    (package private) void
    Tests that the clearSession method works correctly for an already empty session.
    (package private) void
    Tests that deleteById removes the correct result.
    (package private) void
    Tests that deleteById does not remove results from other sessions.
    (package private) void
    Tests that deleteById does not fail for non-existent results.
    (package private) void
    Tests that the findAll method returns the expected search results when available.
    (package private) void
    Tests that the findAllArticles method returns the expected articles when available.
    (package private) void
    Tests that the findAllArticles method returns an empty list when searching for articles in a different session.
    (package private) void
    Tests that the findAllArticles method returns an empty list when no articles are available.
    (package private) void
    Tests that the findAll method returns the expected search results when the maximum capacity is exceeded.
    (package private) void
    Tests that the findAll method returns an empty list when searching for search results in a different session.
    (package private) void
    Tests that the findAll method returns an empty list when no search results are available.
    (package private) void
    Tests that the findAll method returns the expected search results when the maximum capacity is reached.
    (package private) void
    Tests that the findById method returns the expected search result when available.
    (package private) void
    Tests that the findById method returns an empty optional when searching for a search result in a different session.
    (package private) void
    Tests that the findById method returns an empty optional when no search result is available.
    (package private) void
    Tests that the save method adds a search result and returns the expected search result.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • objectMapper

      @Inject @Named("objectMapperTest") com.fasterxml.jackson.databind.ObjectMapper objectMapper
    • repository

      @InjectMocks com.fsf.news.repository.NewsRepository repository
  • Constructor Details

    • NewsRepositoryTest

      NewsRepositoryTest()
  • Method Details

    • testFindByIdEmpty

      @Test void testFindByIdEmpty()
      Tests that the findById method returns an empty optional when no search result is available.
    • testFindById

      @Test void testFindById()
      Tests that the findById method returns the expected search result when available.
    • testFindByIdDifferentSession

      @Test void testFindByIdDifferentSession()
      Tests that the findById method returns an empty optional when searching for a search result in a different session.
    • testDeleteByIdEmpty

      @Test void testDeleteByIdEmpty()
      Tests that deleteById does not fail for non-existent results.
    • testDeleteById

      @Test void testDeleteById()
      Tests that deleteById removes the correct result.
    • testDeleteByIdDifferentSession

      @Test void testDeleteByIdDifferentSession()
      Tests that deleteById does not remove results from other sessions.
    • testFindAllEmpty

      @Test void testFindAllEmpty()
      Tests that the findAll method returns an empty list when no search results are available.
    • testFindAll

      @Test void testFindAll()
      Tests that the findAll method returns the expected search results when available.
    • testFindAllDifferentSession

      @Test void testFindAllDifferentSession()
      Tests that the findAll method returns an empty list when searching for search results in a different session.
    • testFindAllMaxCapacity

      @Test void testFindAllMaxCapacity()
      Tests that the findAll method returns the expected search results when the maximum capacity is reached.
    • testFindAllBeyondCapacity

      @Test void testFindAllBeyondCapacity()
      Tests that the findAll method returns the expected search results when the maximum capacity is exceeded.
    • testFindAllArticlesEmpty

      @Test void testFindAllArticlesEmpty()
      Tests that the findAllArticles method returns an empty list when no articles are available.
    • testFindAllArticles

      @Test void testFindAllArticles() throws IOException
      Tests that the findAllArticles method returns the expected articles when available.
      Throws:
      IOException - If an I/O error occurs
    • testFindAllArticlesDifferentSession

      @Test void testFindAllArticlesDifferentSession() throws IOException
      Tests that the findAllArticles method returns an empty list when searching for articles in a different session.
      Throws:
      IOException - If an I/O error occurs
    • testSave

      @Test void testSave()
      Tests that the save method adds a search result and returns the expected search result.
    • testClearSession

      @Test void testClearSession()
      Tests that the clearSession method removes all search results for a non-empty session.
    • testClearSessionEmpty

      @Test void testClearSessionEmpty()
      Tests that the clearSession method works correctly for an already empty session.